package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;

public class BibliotecaApp {

    private static final String WELCOME_TO_BANGALORE_PUBLIC_LIBRARY = "Welcome to Bangalore Public Library";
    private BufferedReader reader;
    private PrintStream printStream;
    private List<String> initialMenuOptions = Arrays.asList("Enter 1 to log in as guest.", "Enter 2 to log in as user.");
    private ValidateInMap validateInMap;

    public BibliotecaApp(BufferedReader reader, PrintStream ps, ValidateInMap validateInMap) {
        this.reader = reader;
        this.printStream = ps;
        this.validateInMap = validateInMap;
    }

    public void startApp() throws IOException {
        Menu mainMenu = new Menu(printStream, reader, initialMenuOptions);
        mainMenu.displayMenuOptions();
        String userMenuChoice = mainMenu.promptUserInput();
        validateInMap.mapToMenu(userMenuChoice);
    }

    public void printWelcomeMessage(){
        printStream.println(WELCOME_TO_BANGALORE_PUBLIC_LIBRARY);
    }

}
